package cn.db101.jcc.service;

import cn.db101.jcc.entity.Favorites;
import cn.db101.jcc.mapper.LineupMapper;
import cn.db101.jcc.entity.Lineup;
import com.mybatisflex.core.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

import static cn.db101.jcc.entity.table.Tables.LINEUP;

/**
 * @author Administrator
 * @description 针对表【t_lineup】的数据库操作Service实现
 * @createDate 2024-06-11 11:10:17
 */
@Service
public class LineupService {

    @Autowired
    private LineupMapper lineupMapper;

    public List<Lineup> lineupList(int categoryId) {

        return lineupMapper.selectListByQuery(QueryWrapper.create()
                    .where(LINEUP.CATEGORY_ID.eq(categoryId))
                    .orderBy(LINEUP.CREATE_TIME, false));
    }

    public Lineup lineupOne(int id) {

        return lineupMapper.selectOneByQuery(QueryWrapper.create().where(LINEUP.ID.eq(id)));
    }

    public List<Lineup> listFromId(List<Integer> idList) {

        return lineupMapper.selectListByQuery(QueryWrapper.create().in(Lineup::getId, idList));
    }

    public void save(Lineup lineup) {

        lineupMapper.insert(lineup);
    }
}




